package com.audaque.springboot.foshanupload.web.webdemo.model.qo;



import com.audaque.springboot.foshanupload.core.converter.DateJacksonDeserializeConverter;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.*;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;


import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;

/**
 * <p>
 * 日期序列化
 *
 * </p>
 *
 * @author zgb
 * @since 2021-12-25
 */
@Schema(description = "日期反序列化")
@Data

@NoArgsConstructor
@AllArgsConstructor

public class DateJacksonDesSerializeQo implements Serializable {
    private static final long serialVersionUID = -1242493306307174690L;

    @Schema(description = "id")
    private Long id;

    @NotBlank
    @Schema(description = "更新时间")
    //时间戳或者是yyyy-MM-dd格式的日期，Jackson会自动识别并且转换成功
    private Date updateDate;

    @NotBlank
    @Schema(description = "删除时间")
    //添加两个注解
    //用于post的boday的json
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    //用于get的params
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date deleteDate;



    @NotBlank
    @Schema(description = "事件时间")
    //注解
    //解决：yyyy-MM-dd HH:mm:ss这种格式的日期字符串的话，Jackson无法自动转换成Date类型。
    @JsonDeserialize(using = DateJacksonDeserializeConverter.class)
    private Date eventDate;

    @NotBlank
    @Schema(description = "上报时间,yyyy-MM-dd HH:mm:ss")
    //全局
    //DateJacksonDeserializeConverter配置Jackson2ObjectMapperFactoryBean的作用
    private Date createDate;

}
